<?php
require_once __DIR__ . '/../helpers/helper.php';
require_once __DIR__.'/../vendor/autoload.php';

try {
    (new Dotenv\Dotenv(dirname(__DIR__)))->load();
} catch (Dotenv\Exception\InvalidPathException $e) {
    //
}

/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| Here we will load the environment and create the application instance
| that serves as the central piece of this framework. We'll use this
| application as an "IoC" container and router for this framework.
|
*/

$app = new Laravel\Lumen\Application(
    dirname(__DIR__)
);

$app->withFacades();

$app->withEloquent();

/*
|--------------------------------------------------------------------------
| Register Container Bindings
|--------------------------------------------------------------------------
|
| Now we will register a few bindings in the service container. We will
| register the exception handler and the console kernel. You may add
| your own bindings here if you like or you can make another file.
|
*/

$app->singleton(
    Illuminate\Contracts\Debug\ExceptionHandler::class,
    App\Exceptions\Handler::class
);

$app->singleton(
    Illuminate\Contracts\Console\Kernel::class,
    App\Console\Kernel::class
);

/*
|--------------------------------------------------------------------------
| Register Middleware
|--------------------------------------------------------------------------
|
| Next, we will register the middleware with the application. These can
| be global middleware that run before and after each request into a
| route or middleware that'll be assigned to some specific routes.
|
*/

// $app->middleware([
//     App\Http\Middleware\SensitiveWordFilteringMiddleware::class
// ]);

 $app->middleware([
     App\Http\Middleware\PvLogMiddleware::class
 ]);

 $app->routeMiddleware([
     'word_filter' => App\Http\Middleware\SensitiveWordFilteringMiddleware::class,
     'check_access_token' => App\Http\Middleware\CheckAccessToken::class,
     'aes_encry' => App\Http\Middleware\AesEncry::class,
 ]);

/*
|--------------------------------------------------------------------------
| Register Service Providers
|--------------------------------------------------------------------------
|
| Here we will register all of the application's service providers which
| are used to bind services into the container. Service providers are
| totally optional, so you are not required to uncomment this line.
|
*/

//$app->register(App\Providers\AppServiceProvider::class);
// $app->register(App\Providers\AuthServiceProvider::class);
$app->register(App\Providers\EventServiceProvider::class);//开启事件监听 2018/12/25

/*
|--------------------------------------------------------------------------
| Load The Application Routes
|--------------------------------------------------------------------------
|
| Next we will include the routes file so that they can all be added to
| the application. This will provide all of the URLs the application
| can respond to, as well as the controllers that may handle them.
|
*/
$app->register(Illuminate\Redis\RedisServiceProvider::class);
$bathPath = $app->basePath();
$app->router->group([
    'namespace' => 'App\Http\Controllers',
], function ($router) use ($bathPath) {
    require __DIR__.'/../routes/api.php';
    require __DIR__.'/../routes/version.php';
    require __DIR__ . '/../app/Lib/functions.php';
    require __DIR__ . '/../app/Lib/TimeHelper.php';
});

//cms后台调用专用路由文件
$app->router->group(['namespace' => 'App\Http\Controllers\CmsApi'], function ($router) {
    require __DIR__.'/../routes/cmsapi.php';
});


$app->configure('redis');
// $app->configure('ucpaas');
$app->configure('pay');
// $app->configure('youme');
$app->configure('thirdpart_login');
$app->configure('alipay');
$app->configure('animation');
// $app->configure('cloud_account');
// $app->configure('cloud_account_dev');
$app->configure('bank');
$app->configure('queue');
// $app->configure('xfyun_voice');
$app->configure('voice_rule');
$app->configure('agora');
// $app->configure('umeng');
// $app->configure('three_space');
// $app->configure('rong_filter');
$app->configure('agora_aig');
// $app->configure('cloud_account_large');
// $app->configure('cloud_account_large_dev');
$app->configure('cooperate');
$app->configure('agreement');
$app->configure('message');
$app->configure('bls_dev');
$app->configure('bls');

//慧用工
$app->configure('yuque_dev');
$app->configure('yuque');
//即构
$app->configure('zego');
//腾域短信
$app->configure('tengyu');
//极光一键登录
$app->configure('jg');
//融云
$app->configure('rong_cloud');
//阿里云oss
$app->configure('oss');
//数美
// $app->configure('sumei');
// $app->configure('shumei_filter');
//elastic
$app->configure('es');
//阿里云验证码
$app->configure('ali_verify');
//短信验证码配置
$app->configure('sms');
//腾讯人脸
$app->configure('tx_face');



return $app;
